// 文章详情
.row {
  display: flex;
  box-sizing: border-box;
}

.justify-position {
  justify-content: space-between;
}

.main-content {
  if (hexo-config('toc.on')) {
    width: 65%;
    margin-right: 10px;
    margin-left: calc(35% - 355px);
  } else {
    width: 75%;
    margin: 0 auto;
  }

  margin-top: 10px;
  transition: width 0.3s;
}

#waifu #live2d {
  margin-left: -50px;
}

.toc-aside {
  color: $color-post-toc;
  width: 300px;
  padding: 0 10px;
  background-color: rgba(255, 255, 255, $color-post-tocOpacity);
  // transition: width 0.3s;

  @media screen and (max-width: 992px) {
    & {
      position: fixed;
      right: -100%;
      bottom: 50px;
      z-index: 100;
      max-height: calc(100% - 80px);
      width: 300px;
      background-color: #fff;
      opacity: 0;
      -webkit-transform-origin: right bottom;
      -moz-transform-origin: right bottom;
      -o-transform-origin: right bottom;
      -ms-transform-origin: right bottom;
      transform-origin: right bottom;
      margin-top: 1rem;
      padding: 1.5rem 1.2rem;
      padding-top: 0;
      box-sizing: border-box;
    }
  }

  .toc-content {
    max-height: calc(100vh - 150px);

    @media screen and (max-width: 551px) {
      max-height: calc(100vh - 170px);
    }

    overflow: auto;
    display: inline-block;
    width: 100%;
    box-sizing: border-box;

    .toc-list {
      padding-left: 35px;
    }

    .is-collapsible {
      padding-left: 15px;
    }

    if (hexo-config('toc.showOrderNumber')) {
      .toc-list li {
        list-style: decimal;
      }
    }

    .toc-list-item a {
      transition: color 0.3s;
    }

    .toc-list-item a:hover {
      color: $color-primary;
    }
  }

  .toc-aside-title {
    font-size: 1.5rem;
    font-weight: bold;
    line-height: 1.5rem;
    margin: 25px 0 15px 0;
    position: relative;

    .toc-open-close {
      position: absolute;
      top: 150px;
      left: -25px;
      width: 25px;
      height: 60px;
      font-size: 12px;
      background-color: #fa0;
      color: #ffffff;
      text-align: center;
      writing-mode: vertical-rl;
      border-radius: 5px;
      cursor: url('../../medias/cursor/Horizontal.cur'), text;

      @media screen and (max-width: 992px) {
        display: none;
      }
    }

    i {
      margin-right: 10px;
    }
  }
}

#toc-mobile-btn {
  display: none;

  @media screen and (max-width: 992px) {
    display: block;
    position: fixed;
    width: 50px;
    height: 50px;
    line-height: 50px;
    bottom: 140px;
    right: 17px;
    text-align: center;
    z-index: 999;
    background-color: $color-primary;
    color: $color-inner;
    border-radius: 50%;
    box-shadow: -2px 2px 2px 2px rgba(255, 255, 255, 0.5);
  }

  @media screen and (max-width: 551px) {
    width: 30px;
    height: 30px;
    line-height: 30px;
    bottom: 100px;
    right: 0;
  }
}

@keyframes toc-open {
  0% {
    transform: scale(0.7);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes toc-close {
  0% {
    transform: scale(1);
  }

  100% {
    transform: scale(0.7);
  }
}

.post-detail {
  padding: 20px 40px;
  color: #273849;
  -webkit-font-smoothing: antialiased;
  line-height: 1.6rem;
  letter-spacing: 0;
  margin: 0;
  overflow-x: hidden;
  background-color: alpha(#fff, $color-post-contentOpacity);
  border-radius: 10px;
  box-shadow: 0 0 5px #ccc;
  font-family: $color-post-fontFamily;
  position: relative;

  .post-title {
    text-align: center;
    font-size: 1.6em;
    color: #273849;
    font-weight: 700;
    margin: 10px 0 30px 0;
  }

  .post-tags-categories {
    display: flex;
    justify-content: flex-end;
    margin: 10px 0;

    .tags, .category {
      margin-right: 10px;
    }

    .tags {
      a {
        display: inline-block;
        border: 1px solid $color-primary;
        color: $color-primary !important;
        padding: 2px 20px;
        border-radius: 20px;
        margin-top: 10px;

        &:hover {
          color: $color-inner !important;
          background-color: $color-primary;
        }
      }
    }
  }

  .post-content {
    margin-top: 20px;

    .headerlink {
      position: relative;
    }

    h1:hover .headerlink::before, h2:hover .headerlink::before, h3:hover .headerlink::before, h4:hover .headerlink::before, h5:hover .headerlink::before, h6:hover .headerlink::before {
      opacity: 1;
    }

    .headerlink::before {
      content: '#';
      position: absolute;
      left: -15px;
      top: 50%;
      transform: translateY(-50%);
      opacity: 0;
      transition: all 0.3s;
      color: $color-primary;
    }
  }

  img {
    max-width: 100%;
    margin: 0 50%;
    transform: translateX(-50%);
  }

  .gallery, .btns, .site-card {
    img {
      margin: 0;
      transform: translateX(0);
    }
  }

  blockquote {
    border-left: 5px solid #42b983;
    padding: 1rem 0.8rem 0.2rem 0.8rem;
    background-color: rgba(66, 185, 131, 0.1);
    margin: 0;
    word-break: break-all;
  }

  if (hexo-config('color_scheme.post.codeBackground')) {
    :not(pre) > code[class*='language-'], pre[class*='language-'] {
      background-color: $color-post-code-background;
    }
  }

  code:not([class *='language'] ) {
    padding: 1px 5px;
    top: 13px !important;
    font-family: Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace;
    font-size: 0.91rem;
    color: $color-post-p-light;
    // background-color: #f8f8f8;
    background-color: alpha(#f8f8f8, $color-post-contentOpacity);
    border-radius: 2px;
  }

  /* 代码块复制按钮 */
  .codeBox {
    /* 方便copy代码按钮（btn-copy）的定位 */
    position: relative;

    .btn-copy {
      display: inline-block;
      cursor: pointer;

      if (hexo-config('color_scheme.post.copyBackground')) {
        background-color: $color-post-copy-background;
        border: 1px solid $color-post-copy-background;
      } else {
        background-color: $color-primary;
        border: 1px solid $color-primary;
      }

      -webkit-user-select: none;
      -moz-user-select: none;
      -ms-user-select: none;
      user-select: none;
      -webkit-appearance: none;
      font-size: 13px;
      font-weight: 700;
      line-height: 20px;

      if (hexo-config('color_scheme.post.copyColor')) {
        color: $color-post-copy-font;
      } else {
        color: $color-inner;
      }

      -webkit-transition: opacity 0.3s ease-in-out;
      -o-transition: opacity 0.3s ease-in-out;
      transition: opacity 0.3s ease-in-out;
      padding: 2px 6px;
      position: absolute;
      right: 5px;
      top: 5px;
      opacity: 0;
    }

    .btn-copy span {
      margin-left: 5px;
    }
  }

  .codeBox:hover .btn-copy {
    opacity: 1;
  }

  .codeBox:hover .btn-copy:hover {
    background-color: $color-button + 10 * 2% + 1 * 0.5deg;
  }

  /* 代码块复制按钮 */
  :root {
    --side-bar-bg-color: #fff;
    --control-text-color: #777;
    --font-sans-serif: 'Ubuntu', 'Source Sans Pro', sans-serif !important;
    --font-monospace: 'Fira Code', 'Roboto Mono', monospace !important;
  }

  a:not(.toc-link) {
    color: #42b983;
    font-weight: 600;
    padding: 0 2px;
    text-decoration: none;
  }

  h1, h2, h3, h4, h5, h6 {
    // position: relative;
    margin-top: 1rem;
    margin-bottom: 1rem;
    font-weight: bold;
    line-height: 1.4;
    cursor: $cursor-text, text;
    color: $color-post-title;
  }

  h1:focus, h2:focus, h3:focus, h4:focus, h5:focus, h6:focus {
    outline: none;
  }

  h1:hover a.anchor, h2:hover a.anchor, h3:hover a.anchor, h4:hover a.anchor, h5:hover a.anchor, h6:hover a.anchor {
    text-decoration: none;
  }

  h1 tt, h1 code {
    font-size: inherit !important;
  }

  h2 tt, h2 code {
    font-size: inherit !important;
  }

  h3 tt, h3 code {
    font-size: inherit !important;
  }

  h4 tt, h4 code {
    font-size: inherit !important;
  }

  h5 tt, h5 code {
    font-size: inherit !important;
  }

  h6 tt, h6 code {
    font-size: inherit !important;
  }

  h2 a, h3 a {
    color: #273849;
  }

  h1 {
    padding-bottom: 0.4rem;
    font-size: 2.2rem;
    line-height: 1.3;
  }

  h2 {
    font-size: 1.75rem;
    line-height: 1.225;
    margin: 35px 0 15px;
    padding-bottom: 0.5em;
    border-bottom: 1px solid #ddd;
  }

  h3 {
    font-size: 1.4rem;
    line-height: 1.43;
    margin: 20px 0 7px;
  }

  h4 {
    font-size: 1.2rem;
  }

  h5 {
    font-size: 1rem;
  }

  h6 {
    font-size: 1rem;
    color: #777;
  }

  p {
    color: $color-post-p;
  }

  p, blockquote, ul, ol, dl, table {
    margin: 0.8em 0;
  }

  li > ol, li > ul {
    margin: 0 0;
  }

  hr {
    height: 2px;
    padding: 0;
    margin: 16px 0;
    background-color: #e7e7e7;
    border: 0 none;
    overflow: hidden;
    box-sizing: content-box;
  }

  a:first-child h1, a:first-child h2, a:first-child h3, a:first-child h4, a:first-child h5, a:first-child h6 {
    margin-top: 0;
    padding-top: 0;
  }

  h1 p, h2 p, h3 p, h4 p, h5 p, h6 p {
    margin-top: 0;
  }

  li p.first {
    display: inline-block;
  }

  ul, ol {
    padding-left: 30px;
  }

  ul:last-child, ol:last-child {
    margin-bottom: 0;
  }

  blockquote {
    padding: 12px 24px 12px 30px;
    border-left-width: 4px;
    border-left-style: solid;
    border-radius: 4px;
    margin: 1rem 0;
    background-color: rgba(66, 185, 131, 0.1);
    border-color: $color-primary;
    position: relative;

    &::before {
      content: '\f129';
      background-color: $color-primary;
      position: absolute;
      top: 14px;
      left: -12px;
      color: #fff;
      width: 20px;
      height: 20px;
      border-radius: 100%;
      text-align: center;
      line-height: 20px;
      font-weight: bold;
      font-family: 'Font Awesome 5 Pro'; // Font Awesome 5 Free
      font-weight: 600;
      font-size: 14px;
    }
  }

  table {
    padding: 0;
    word-break: initial;
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    border-spacing: 0;
    overflow: auto;
  }

  table tr {
    border-top: 1px solid #dfe2e5;
    margin: 0;
    padding: 0;
  }

  table tr:nth-child(2n), thead {
    background-color: alpha(#fafafa, $color-post-contentOpacity);
  }

  table tr th {
    font-weight: bold;
    border: 1px solid #dfe2e5;
    border-bottom: 0;
    text-align: left;
    margin: 0;
    padding: 6px 13px;
  }

  table tr td {
    border: 1px solid #dfe2e5;
    text-align: left;
    margin: 0;
    padding: 6px 13px;
    word-wrap: break-word;
  }

  table tr th:first-child, table tr td:first-child {
    margin-top: 0;
  }

  table tr th:last-child, table tr td:last-child {
    margin-bottom: 0;
  }

  p {
    margin: 2px 2px 10px;
    font-size: 1.05rem;
    line-height: 1.85rem;
  }
}

@media (max-width: 992px) {
  .justify-center {
    justify-content: center;
  }

  .main-content {
    width: 100% !important;
    margin: 0 auto !important;
    margin-top: 10px !important;
  }
}

@media (max-width: 551px) {
  .post-detail {
    padding: 15px 15px 20px 18px;
  }
}
